<?php
/*
Plugin Name: DIA-PUCP - Events Manager
Plugin URL: http://dia.pucp.edu.pe/portal/
Description: An events manager that is compilant with the wordpress post's standards but also provides the funcions of multiple events plugins.
Version: 1.1
Author: DIA-PUCP - Kelvin Zevallos Olivos
Author URI: http://dia.pucp.edu.pe/portal/
License: GPLv2
*/

/*
Copyright (c) 2011, PUCP - DIA - Kelvin Zevallos Olivos

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

register_activation_hook( __FILE__, 'diapucp_events_manager_activate');
register_deactivation_hook( __FILE__ , 'dia_pucp_events_manger_deactivate' );


/**
 * Activate the PlugIn
 *
 * Starts the Plugin, checks if the Wordpress current version is compatible and
 * declares all the options required for the pluing to work.
 *
 * @param no parameters.
 * @return no returns.
*/
function diapucp_events_manager_activate(){
    if ( version_compare( get_bloginfo( 'version' ), '3.1', '<' ) ) {
        deactivate_plugins( basename( __FILE__ ) );
        exit ();
    }
    $dia_pucp_events_manager_options = array(
        'version' => '1.1',
        'plugin_name' => 'diapucp-events-manager',
    );
    update_option('dia-pucp-events-manager-options',$dia_pucp_events_manager_options);
}

/**
 * Deactivate the PlugIn
 *
 * Shutdowns the Plugin without uninstalling all the options and tables declared
 * before. As a caution, the permalink rules are reseted.
 *
 * @param no parameters.
 * @return no returns.
*/
function dia_pucp_events_manger_deactivate(){
    flush_rewrite_rules();
}


//All the file calls requried to do the rest of the work.
require_once dirname( __FILE__ ) . '/includes/libs/utilities.php';

require_once dirname( __FILE__ ) . '/includes/events-init.php';
require_once dirname( __FILE__ ) . '/includes/events-edit-manager.php';
require_once dirname( __FILE__ ) . '/includes/events-showroom.php';
require_once dirname( __FILE__ ) . '/includes/events-shortcodes.php';
require_once dirname( __FILE__ ) . '/includes/events-widget.php';

/*
add_action('wp', 'check_page');
function check_page () {
	if (!is_admin()) {
		add_filter('get_previous_post_sort', 'sort_it');
		add_filter('get_next_post_sort', 'sort_it');
		add_filter('posts_orderby', 'sort_it' );
		add_filter('posts_join', 'join_it' );
		add_filter('posts_where', 'where_it' );

		function sort_it () {
			global $wpdb;

			return " $wpdb->postmeta.meta_value DESC ";
		}

		function join_it( $join ) {
			global $wpdb;

			$join .= " LEFT JOIN $wpdb->postmeta ON($wpdb->posts.ID = $wpdb->postmeta.post_id) ";

		  return $join;
		}

		function where_it( $where ) {
			global $wpdb;
			$where .= "AND $wpdb->postmeta.meta_key = 'Price' ";

		  return $where;
		}
	}
}
*/

/*
add_action('admin_menu', 'dia_pucp_create_settings_menu');

function dia_pucp_create_settings_menu(){
    add_menu_page('My Plugin Settings', 'Plugin Styling', 'manage_options', __FILE__, 'dia_pucp_styling_settings' );
}

function dia_pucp_styling_settings(){
    ?>
    <div class="wrap">
         <?php screen_icon('plugins'); ?>
         <h2>My Plugin</h2>
    </div>
    <?php
}
*/

?>
